# -*- coding:utf-8 -*-
"""
@author: fsksf

@since: 2022/4/20 21:00
定义主路由、子路由
"""
from vcat.server.obj import MainRoutes, Children

MAIN_ROUTES_OVERVIEW = MainRoutes(path='/overview', children=[], name='overview',
                                  meta={'title': '总览', 'icon': 'el-icon-s-help'}, redirect=None)
MAIN_ROUTES_BROKER = MainRoutes(name='broker', path='/broker', children=[],
                                meta={'title': '通道', 'icon': 'el-icon-sort'},
                                redirect=None)
MAIN_ROUTES_ANALYZE = MainRoutes(name='analyze', path='/analyze', children=[],
                                 meta={'title': '分析', 'icon': 'el-icon-data-line'},
                                 redirect=None)
MAIN_ROUTES_STRATEGY = MainRoutes(name='strategy', path='/strategy', children=[],
                                  meta={'title': '策略', 'icon': 'el-icon-cpu'},
                                  redirect=None)
MAIN_ROUTES_LOG = MainRoutes(name='log', path='/log', children=[],
                             meta={'title': '日志', 'icon': 'el-icon-document'},
                             redirect=None)


ALL_ROUTES = (
    MAIN_ROUTES_OVERVIEW,
    MAIN_ROUTES_BROKER,
    MAIN_ROUTES_ANALYZE,
    MAIN_ROUTES_STRATEGY,
    MAIN_ROUTES_LOG
)


def as_page(main: MainRoutes):

    def wp(obj: Children):
        main.children.append(obj)
        return obj
    return wp


as_page(MAIN_ROUTES_OVERVIEW)(
    Children(name='overview',
             path='overview',
             meta={'title': '总览', 'icon': 'el-icon-s-help'},
             props={'pageName': 'overview', 'title': '总览'},
             component='table')
)

as_page(MAIN_ROUTES_LOG)(
    Children(name='log', path='log',
             meta={'title': '日志', 'icon': ''},
             props={'pageName': 'log', 'title': '日志'},
             component='table')
)

as_page(MAIN_ROUTES_STRATEGY)(
    Children(name='strategyClass', path='strategyClass',
             meta={'title': '策略类', 'icon': ''},
             props={'pageName': 'strategyClass', 'title': '策略类'},
             component='strategyInit')
)

as_page(MAIN_ROUTES_STRATEGY)(
    Children(name='strategyIns', path='strategyIns',
             meta={'title': '运行中的策略', 'icon': ''},
             props={'pageName': 'strategyIns', 'title': '运行中的策略'},
             component='table')
)